<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>08-循环随堂练习</title>
</head>
<body>
<script>
    /*
        在控制台打印出一个四行的直角三角形和等腰三角形
     */
    var str = "";
    for (let i = 0; i < 4; i++) {
        for (let j = 0; j < 4 - i - 1; j++) {
            str += " ";
        }
        for (let j = 0; j <= i; j++) {
            str+="*";
        }
        str+="\n";

    }
    console.log(str);

    let str1="";
    for (let i = 0; i < 4; i++) {
        for (let j = 0; j < 4 - i - 1; j++) {
            str1+=" ";
        }
        for (let j = 0; j <=i*2; j++) {
            str1+="*";
        }
        for (let j = 0; j < 4 - i - 1; j++) {
            str1+=" ";
        }
        str1+="\n";
    }
    console.log(str1);

    /*
        统计[1-100]之间有多少个质数
     */
    var count=0;
    for (let i = 2; i <= 100; i++) {
        for (let j = 2; j < i; j++) {
            if (i%j==0){
                count++;
                break;
            }
        }
    }
    console.log("1-100之间一共有"+(99-count)+"个质数");

</script>
</body>
</html>